#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;

long long n, anscnt, a[200005];
vector<long long> ans[200005];

int main()
{
	freopen( "fruit.in", "r", stdin );
	freopen( "fruit.out", "w", stdout );
	scanf( "%lld", &n );
	for( long long i = 1; i <= n; i++ )
	{
		scanf( "%lld", &a[i] );
	}
	for( long long i = 1; i <= n; i++ )
	{
		long long tmp = 1;
		while( ans[tmp].size() )
		{
			if( a[ans[tmp][ans[tmp].size() - 1]] == a[i] )
			{
				tmp++;
			}
			else
			{
				break;
			}
		}
		ans[tmp].push_back( i );
		anscnt = max( anscnt, tmp );
	}
	for( long long i = 1; i <= anscnt; i++ )
	{
		for( long long j = 0; j < ans[i].size(); j++ )
		{
			printf( "%lld ", ans[i][j] );
		}
		putchar( '\n' );
	}
	return 0;
}
